indusfandomcom-20200214-history
Declarations
2.1 Agent and Component declarations An Agent or Component declaration specifies a new Agent or Component. AgentDeclaration: AgentModifieropt Agent Identifier AgentBody ComponentDeclaration: ComponentModifieropt Component Identifier ComponentBody The Identifier in a declaration specifies the name of the Agent or Component. A compile time error occurs if an Agent or Component has the same simple name as any of its enclosing members. 2.1.1 Agent and Component Modifiers An Agent or Component declaration may include the following modifiers. public abstract static strictfp The access modifier static pertains to only member Agents and Components. A compile time error occurs if the same modifier appears more than once in an Agent or Component declaration. Every Agent and Component is implicitly abstract and public. The effect of the strictfp modifier is to make all float or double expressions within the Agent or Component declaration be explicitly FP-strict. 2.1.2 Agent and Component members Indus does not use extends clause for extension of interface behavioral specification. Instead, Agents and Components allow other Agents and Components to be members thus implying that they extend their behavioral specification. Any class that implements the declared Agent or Component is also considered to implement all the Agents and Components that the declared Agent or Component has members. However, to be members, Agents and Components need to be accessible. Agents and Components cannot be recursive that is they cannot depend on themselves. An Agent or Component K is a supertype of I if either of the following is true: K is a direct supertype of I There exists an Agent or Component J such that K is a supertype of J and J is a supertype of I A compile time error occurs if Agents and Components depend on themselves or are declared recursively. 2.1.3 Agent and Component Body and Members The body of an Agent or Component may declare members of the Agent or Component. AgenMemberDeclarations: ConstantDeclaration AgentDeclaration ComponentDeclaration AbstractMethodDeclaration ; ComponentMemberDeclarations: ConstantDeclaration PortDeclaration ComponentDeclaration ; The scope of the declaration of a member m declared in or inherited by an Agent or Component I is the entire body of I, including any nested type declarations. 2.2 Agent and Component Members The members of an Agent or Component are Those members declared in the Agent or Component Those members inherited from direct super types Implicitly public 2.2.1 Field (Constant) Declarations Every field declaration in the body of a Agent or Component is implicitly public, static and final. If the Agent or Component declares a field with a certain name, then the declaration of that field is said to hide any and all accessible declarations of fields with the same name in the Agent’s or Component’s super types. Every field in the body of an Agent or Component must have an initialization expression, which need not be a constant expression. A compile-time error will result in the following cases: Field declarations with the same name Reference to fields with the same name inherited from super types Where an initialization expression for an Agent or Component field contains a reference by a simple name to the same field or to another field whose declaration occurs textually later in the same Agent or Component or by reference by the simple name to the same field contained in the Agent’s or Component’s super type 2.2.2 Abstract Method Declarations Methods are always public and abstract. A compile time error occurs if Agent or Component declare methods that are static (as that conflicts with the fact that they are abstract as well) Agent or Component declare methods that are final If the same modifier appears more than once in the method declaration The methods declared are specified as strictfp, native or synchronized Two methods in an Agent or Component declaration have the same signature If an Agent or Component declares a method, then the declaration of that method is said to override any and all methods with the same signature in the super types of the Agent or Component. A compile time error occurs if If over ridden method do not share the same return type with the method overriding it If the over ridden method has a throws clause that conflicts with that of any methods that over ride it Two inherited methods with the same signature in an Agent or Component declaration are referred to when the methods do not have the same return types (conflicting throws clauses will not cause an error in this case) Methods are overridden on a signature-by-signature basis. If, for example, an Agent or Component declares two methods with the same name but different signatures (different number of parameters or return types), and an Agent or Component overrides one of them, the other method is still inherited. If two methods of an Agent or Component (whether both declared in the same Agent or Component, or both inherited by an Agent or Component, or one declared and one inherited) have the same name but different signatures, then the method name is said to be overloaded. This fact doesn’t cause any difficulty in compilation.